function [s, Lambda] = CoSaMP(Phi, u, s)

% [s, Lambda] = CoSaMP(Phi, u, s)
%
% Model:
% v = Phi * s
%
% Input argument:
% Phi is a N by d sensing matrix.
% v is an observed n-dimensional signal
% m is m-sparse
%
% Output argument:
% s is recoveried signal
% Lambda is a set of none zero location of s.
%  
% Reference:
% <<Signal Recovery From Random Measurements Via Orthogonal Matching Pursuit>>, Joel A. Tropp, and Anna c. Gilbert
%
% Author: 
% Cao Jin, xlscaoj@gmail.com
% 
% History:
% 2012/5/21: Initail release


% Initialize

  % [N, d] = size(Phi);
  % s_hat = zeros(d, 1);
  % Lambda = [];
      a = 0;
      v = u;
      y = zeros(N);

      for t = 1 : m
          y = Phi' * v;
          omega = find(y);
          T = [omega, find(a)];
          b = zeros(N);
          b = pinv(Phi(:,T)) * u;
      end

      s = s_hat;
